import os
import pytest
from common.api import Api
from common.read import read
from common.ApiServer import ApiServer
from common.YamlUtil import YamlUtil
# 登录接口
@pytest.fixture(scope="session")
def login_token():
    username = read.read_yaml()['login_fixture']['username']
    passwd = read.read_yaml()['login_fixture']['password']
    json_data = {"username": username, "password": passwd}
    #登录接口
    res = Api().post('/login/', json=json_data)
    assert len(res['token']) != 0
    token = res["token"]
    headers = {"authorization": "JWT "+ token}
    return headers


# @pytest.mark.parametrize("test_data",YamlUtil().read_testcase_yaml("user_center.yaml","user_login"))
# def login(test_data):
#     res = ApiServer.handle_case(test_data)
#     return res